#ifndef fdmU2d_H
#define fdmU2d_H

#include "fdmU2d.h"

#include <bits/stdc++.h>

#include "diff2d.h"

namespace fdmU2d{
    static string scheme;
    static int schemeNum;
    static double resMin;
    static double sorFac=1;
    int iter(diff2D::diffList diffFun,int xNum,int yNum,double **x0,double **b,double **x1);
    int jaccobi(diff2D::diffList diffFun,int xNum,int yNum,double **x0,double **b,double **x1);
    int gaussSeidel(diff2D::diffList diffFun,int xNum,int yNum,double **x0,double **b,double **x1);
    int sor(diff2D::diffList diffFun,int xNum,int yNum,double **x0,double **b,double **x1);
    class conjGrad{
        public:
            int inited=0;
            void init(diff2D::diffList diffFun,int xNum,int yNum,double **x0,double **b,double **x1);
            int iter(diff2D::diffList diffFun,int xNum,int yNum,double **x0,double **b,double **x1);
            double **r0;
            double **r1;
            double **p0;
            double **p1;
    };
    static conjGrad conjGradIter;
    int copyBc(int xNum,int yNum,double **x0,double **x1);
    int readScheme(char *fileName);

    double dot(double **vec1,double **vec2,int xNum,int yNum);
    double **matVec(diff2D::diffList diffFun,double **vec,int xNum,int yNum);
    int updateVec(double **vec0,double **vec1,int xNum,int yNum);
}

#endif